﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace YunBox2.Client.Infrastructure
{
    /// <summary>
    /// CompanyProflieDiaglog.xaml 的交互逻辑
    /// </summary>
    public partial class CompanyProflieDiaglog : Window
    {
        public CompanyProflieDiaglog()
        {
            InitializeComponent();
			
			DataContext=new ViewModels.CompanyProfileViewModel();
        }

        ViewModels.CompanyProfileViewModel ViewModel
        {
            get
            {
                return DataContext as ViewModels.CompanyProfileViewModel;
            }
            //set
            //{
            //    DataContext = value;
            //}
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if(!ViewModel.IsEnableSave)
            {
                MessageBoxResult re = MessageBox.Show("资料尚未保存,是否保存后关闭?", "提示", MessageBoxButton.YesNoCancel);
                if(re==MessageBoxResult.Yes)
                {
                    ViewModel.SaveCommand.Execute(null);
                }
                else if(re==MessageBoxResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
            
        }
    }
}
